Patch from HideToshi Tajima (#51922)
authorOwen Taylor <otaylor@redhat.com>
Fri, 2 Nov 2001 20:48:15 +0000 (20:48 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Fri, 2 Nov 2001 20:48:15 +0000 (20:48 +0000)
Fri Nov  2 15:30:34 2001  Owen Taylor  <otaylor@redhat.com>

        Patch from HideToshi Tajima (#51922)

        * gtk/gtkimmulticontext.c: Proxy set_use_preedit().

        * gtk/modules/input/gtkimcontextxim.[ch]: Implement
        set_use_preedit().

        * gtk/modules/input/gtkimcontextxim.[ch]: If we have
        to destroy the input context because we change the
        client window or use_preedit, make sure we empty
        the preedit string.

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkimmulticontext.c
modules/input/gtkimcontextxim.c
modules/input/gtkimcontextxim.h

index b04af65e894722df8055c3b367c2c95f2f494e07..13917d55dc641f6fb740fc2ae2f009de0133116a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+Fri Nov  2 15:30:34 2001  Owen Taylor  <otaylor@redhat.com>
+
+       Patch from HideToshi Tajima (#51922)
+       
+       * gtk/gtkimmulticontext.c: Proxy set_use_preedit().
+
+       * gtk/modules/input/gtkimcontextxim.[ch]: Implement
+       set_use_preedit().
+       
+       * gtk/modules/input/gtkimcontextxim.[ch]: If we have
+       to destroy the input context because we change the
+       client window or use_preedit, make sure we empty
+       the preedit string.
+
 Fri Nov  2 14:55:53 2001  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/{gtkcolorseldialog.c,gtkfilesel.c,gtkfontsel.c,
index b04af65e894722df8055c3b367c2c95f2f494e07..13917d55dc641f6fb740fc2ae2f009de0133116a 100644 (file)
@@ -1,3 +1,17 @@
+Fri Nov  2 15:30:34 2001  Owen Taylor  <otaylor@redhat.com>
+
+       Patch from HideToshi Tajima (#51922)
+       
+       * gtk/gtkimmulticontext.c: Proxy set_use_preedit().
+
+       * gtk/modules/input/gtkimcontextxim.[ch]: Implement
+       set_use_preedit().
+       
+       * gtk/modules/input/gtkimcontextxim.[ch]: If we have
+       to destroy the input context because we change the
+       client window or use_preedit, make sure we empty
+       the preedit string.
+
 Fri Nov  2 14:55:53 2001  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/{gtkcolorseldialog.c,gtkfilesel.c,gtkfontsel.c,
index b04af65e894722df8055c3b367c2c95f2f494e07..13917d55dc641f6fb740fc2ae2f009de0133116a 100644 (file)
@@ -1,3 +1,17 @@
+Fri Nov  2 15:30:34 2001  Owen Taylor  <otaylor@redhat.com>
+
+       Patch from HideToshi Tajima (#51922)
+       
+       * gtk/gtkimmulticontext.c: Proxy set_use_preedit().
+
+       * gtk/modules/input/gtkimcontextxim.[ch]: Implement
+       set_use_preedit().
+       
+       * gtk/modules/input/gtkimcontextxim.[ch]: If we have
+       to destroy the input context because we change the
+       client window or use_preedit, make sure we empty
+       the preedit string.
+
 Fri Nov  2 14:55:53 2001  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/{gtkcolorseldialog.c,gtkfilesel.c,gtkfontsel.c,
index b04af65e894722df8055c3b367c2c95f2f494e07..13917d55dc641f6fb740fc2ae2f009de0133116a 100644 (file)
@@ -1,3 +1,17 @@
+Fri Nov  2 15:30:34 2001  Owen Taylor  <otaylor@redhat.com>
+
+       Patch from HideToshi Tajima (#51922)
+       
+       * gtk/gtkimmulticontext.c: Proxy set_use_preedit().
+
+       * gtk/modules/input/gtkimcontextxim.[ch]: Implement
+       set_use_preedit().
+       
+       * gtk/modules/input/gtkimcontextxim.[ch]: If we have
+       to destroy the input context because we change the
+       client window or use_preedit, make sure we empty
+       the preedit string.
+
 Fri Nov  2 14:55:53 2001  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/{gtkcolorseldialog.c,gtkfilesel.c,gtkfontsel.c,
index b04af65e894722df8055c3b367c2c95f2f494e07..13917d55dc641f6fb740fc2ae2f009de0133116a 100644 (file)
@@ -1,3 +1,17 @@
+Fri Nov  2 15:30:34 2001  Owen Taylor  <otaylor@redhat.com>
+
+       Patch from HideToshi Tajima (#51922)
+       
+       * gtk/gtkimmulticontext.c: Proxy set_use_preedit().
+
+       * gtk/modules/input/gtkimcontextxim.[ch]: Implement
+       set_use_preedit().
+       
+       * gtk/modules/input/gtkimcontextxim.[ch]: If we have
+       to destroy the input context because we change the
+       client window or use_preedit, make sure we empty
+       the preedit string.
+
 Fri Nov  2 14:55:53 2001  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/{gtkcolorseldialog.c,gtkfilesel.c,gtkfontsel.c,
index b04af65e894722df8055c3b367c2c95f2f494e07..13917d55dc641f6fb740fc2ae2f009de0133116a 100644 (file)
@@ -1,3 +1,17 @@
+Fri Nov  2 15:30:34 2001  Owen Taylor  <otaylor@redhat.com>
+
+       Patch from HideToshi Tajima (#51922)
+       
+       * gtk/gtkimmulticontext.c: Proxy set_use_preedit().
+
+       * gtk/modules/input/gtkimcontextxim.[ch]: Implement
+       set_use_preedit().
+       
+       * gtk/modules/input/gtkimcontextxim.[ch]: If we have
+       to destroy the input context because we change the
+       client window or use_preedit, make sure we empty
+       the preedit string.
+
 Fri Nov  2 14:55:53 2001  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/{gtkcolorseldialog.c,gtkfilesel.c,gtkfontsel.c,
index b04af65e894722df8055c3b367c2c95f2f494e07..13917d55dc641f6fb740fc2ae2f009de0133116a 100644 (file)
@@ -1,3 +1,17 @@
+Fri Nov  2 15:30:34 2001  Owen Taylor  <otaylor@redhat.com>
+
+       Patch from HideToshi Tajima (#51922)
+       
+       * gtk/gtkimmulticontext.c: Proxy set_use_preedit().
+
+       * gtk/modules/input/gtkimcontextxim.[ch]: Implement
+       set_use_preedit().
+       
+       * gtk/modules/input/gtkimcontextxim.[ch]: If we have
+       to destroy the input context because we change the
+       client window or use_preedit, make sure we empty
+       the preedit string.
+
 Fri Nov  2 14:55:53 2001  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/{gtkcolorseldialog.c,gtkfilesel.c,gtkfontsel.c,
index 4d4cce66ba7ecdc493ed4992d4734a597240f029..ea51bab2d1ccb9b55b37dd4bf227f1560f3599db 100644 (file)
@@ -45,6 +45,8 @@ static void     gtk_im_multicontext_focus_out          (GtkIMContext
 static void     gtk_im_multicontext_reset              (GtkIMContext            *context);
 static void     gtk_im_multicontext_set_cursor_location (GtkIMContext            *context,
                                                        GdkRectangle            *area);
+static void     gtk_im_multicontext_set_use_preedit    (GtkIMContext            *context,
+                                                       gboolean                 use_preedit);
 static gboolean gtk_im_multicontext_get_surrounding    (GtkIMContext            *context,
                                                        gchar                  **text,
                                                        gint                    *cursor_index);
@@ -115,6 +117,7 @@ gtk_im_multicontext_class_init (GtkIMMulticontextClass *class)
   im_context_class->focus_out = gtk_im_multicontext_focus_out;
   im_context_class->reset = gtk_im_multicontext_reset;
   im_context_class->set_cursor_location = gtk_im_multicontext_set_cursor_location;
+  im_context_class->set_use_preedit = gtk_im_multicontext_set_use_preedit;
   im_context_class->set_surrounding = gtk_im_multicontext_set_surrounding;
   im_context_class->get_surrounding = gtk_im_multicontext_get_surrounding;
 
@@ -321,6 +324,17 @@ gtk_im_multicontext_set_cursor_location (GtkIMContext   *context,
     gtk_im_context_set_cursor_location (slave, area);
 }
 
+static void
+gtk_im_multicontext_set_use_preedit (GtkIMContext   *context,
+                                    gboolean       use_preedit)
+{
+  GtkIMMulticontext *multicontext = GTK_IM_MULTICONTEXT (context);
+  GtkIMContext *slave = gtk_im_multicontext_get_slave (multicontext);
+
+  if (slave)
+    gtk_im_context_set_use_preedit (slave, use_preedit);
+}
+
 static gboolean
 gtk_im_multicontext_get_surrounding (GtkIMContext  *context,
                                     gchar        **text,
index 1285103d400397c5228ecfe3b2b4677e96dcc3cd..2f5faeb3b1e99fb87a14517622532d27af9a88d5 100644 (file)
@@ -42,6 +42,8 @@ static void     gtk_im_context_xim_focus_in           (GtkIMContext          *co
 static void     gtk_im_context_xim_focus_out          (GtkIMContext          *context);
 static void     gtk_im_context_xim_set_cursor_location (GtkIMContext          *context,
                                                       GdkRectangle             *area);
+static void     gtk_im_context_xim_set_use_preedit    (GtkIMContext          *context,
+                                                      gboolean               use_preedit);
 static void     gtk_im_context_xim_get_preedit_string (GtkIMContext          *context,
                                                       gchar                **str,
                                                       PangoAttrList        **attrs,
@@ -216,12 +218,14 @@ gtk_im_context_xim_class_init (GtkIMContextXIMClass *class)
   im_context_class->focus_in = gtk_im_context_xim_focus_in;
   im_context_class->focus_out = gtk_im_context_xim_focus_out;
   im_context_class->set_cursor_location = gtk_im_context_xim_set_cursor_location;
+  im_context_class->set_use_preedit = gtk_im_context_xim_set_use_preedit;
   gobject_class->finalize = gtk_im_context_xim_finalize;
 }
 
 static void
 gtk_im_context_xim_init (GtkIMContextXIM *im_context_xim)
 {
+  im_context_xim->use_preedit = TRUE;
 }
 
 static void
@@ -239,17 +243,28 @@ gtk_im_context_xim_finalize (GObject *obj)
 }
 
 static void
-gtk_im_context_xim_set_client_window (GtkIMContext          *context,
-                                     GdkWindow             *client_window)
+reinitialize_ic (GtkIMContextXIM *context_xim)
 {
-  GtkIMContextXIM *context_xim = GTK_IM_CONTEXT_XIM (context);
-
   if (context_xim->ic)
     {
       XDestroyIC (context_xim->ic);
       context_xim->ic = NULL;
+
+      if (context_xim->preedit_length)
+       {
+         context_xim->preedit_length = 0;
+         g_signal_emit_by_name (context_xim, "preedit_changed");
+       }
     }
+}
 
+static void
+gtk_im_context_xim_set_client_window (GtkIMContext          *context,
+                                     GdkWindow             *client_window)
+{
+  GtkIMContextXIM *context_xim = GTK_IM_CONTEXT_XIM (context);
+
+  reinitialize_ic (context_xim);
   context_xim->client_window = client_window;
 }
 
@@ -425,6 +440,23 @@ gtk_im_context_xim_set_cursor_location (GtkIMContext *context,
   return;
 }
 
+static void
+gtk_im_context_xim_set_use_preedit (GtkIMContext *context,
+                                   gboolean      use_preedit)
+{
+  GtkIMContextXIM *context_xim = GTK_IM_CONTEXT_XIM (context);
+
+  use_preedit = use_preedit != FALSE;
+
+  if (context_xim->use_preedit != use_preedit)
+    {
+      context_xim->use_preedit = use_preedit;
+      reinitialize_ic (context_xim);
+    }
+
+  return;
+}
+
 static void
 gtk_im_context_xim_reset (GtkIMContext *context)
 {
@@ -784,6 +816,15 @@ gtk_im_context_xim_get_ic (GtkIMContextXIM *context_xim)
 
   if (!context_xim->ic && context_xim->client_window)
     {
+      if (!context_xim->use_preedit)
+       {
+         context_xim->ic = XCreateIC (context_xim->im_info->im,
+                                      XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
+                                      XNClientWindow, GDK_DRAWABLE_XID (context_xim->client_window),
+                                      NULL);
+         return context_xim->ic;
+       }
+
       if ((context_xim->im_info->style & PREEDIT_MASK) == XIMPreeditCallbacks)
        {
          context_xim->preedit_start_callback.client_data = (XPointer)context_xim;
index 7d276acd6742f2c1dbd5aa0b466a65c8102fe93b..96d1df5eed44dc4ba0a6a457f5bff8663d4fcfab 100644 (file)
@@ -70,6 +70,8 @@ struct _GtkIMContextXIM
   XIMCallback status_draw_callback;
 
   XIC ic;
+
+  guint use_preedit : 1;
 };
 
 struct _GtkIMContextXIMClass